/**
 s_VS_...: Vertex shader.
 s_FS_...: Fragment Shader.
 ..._g: greyfy the color.
 ..._A: ignore rgb channel of input texture.
 ..._Ag: use alpha channel of input texture as grey channel. ignore rgb.
 */

namespace Zen { namespace GL {

	/**
		particle
		*/
	static const char * s_VS_Point = R""(
	precision highp float;
	attribute vec4 a_coord;
	attribute float a_point_size;
	attribute vec4 a_color;
	uniform mat4 u_transform;
	uniform vec2 u_point_size_ratio;
	varying vec4 v_color;
	void main()
	{
	v_color = a_color;
	gl_PointSize = length((u_transform * vec4(a_point_size, 0.0, 0.0, 0.0)).xy * u_point_size_ratio);
	gl_Position = u_transform * a_coord;
	}
	)"";

	static const char * s_FS_Point = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	uniform sampler2D u_sampler;
	void main()
	{
	gl_FragColor = texture2D(u_sampler, gl_PointCoord) * v_color * u_color;
	}
	)"";

	static const char * s_FS_Point_g = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	uniform sampler2D u_sampler;
	const highp vec3 grey = vec3(0.21, 0.71, 0.08);
	void main()
	{
	vec4 c = texture2D(u_sampler, gl_PointCoord) * v_color;
	float i = dot(c.rgb, grey);
	gl_FragColor = vec4(i, i, i, c.w) * u_color;
	}
	)"";

	static const char * s_FS_Point_A = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	uniform sampler2D u_sampler;
	void main()
	{
	vec4 c = v_color * u_color;
	float a = texture2D(u_sampler, gl_PointCoord).w;
	gl_FragColor = vec4(c.rgb, c.w * a);
	}
	)"";

	static const char * s_FS_Point_Ag = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	uniform sampler2D u_sampler;
	void main()
	{
	float i = texture2D(u_sampler, gl_PointCoord).w;
	gl_FragColor = vec4(i, i, i, 1) * v_color * u_color;
	}
	)"";


	/**
		color
		*/
	static const char * s_VS_Color = R""(
	precision highp float;
	attribute vec4 a_coord;
	attribute vec4 a_color;
	uniform mat4 u_transform;
	varying vec4 v_color;
	void main()
	{
	v_color = a_color;
	gl_Position = u_transform * a_coord;
	}
	)"";

	static const char * s_FS_Color = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	void main()
	{
	gl_FragColor = v_color * u_color;
	}
	)"";

	static const char * s_FS_Color_g = R""(
	precision highp float;
	varying vec4 v_color;
	uniform vec4 u_color;
	const highp vec3 grey = vec3(0.21, 0.71, 0.08);
	void main()
	{
	float i = dot(v_color.rgb, grey);
	gl_FragColor = vec4(i, i, i, v_color.w) * u_color;
	}
	)"";

	/**
		sampler
		*/
	static const char * s_VS_Texture = R""(
	precision highp float;
	attribute vec4 a_coord;
	attribute vec2 a_tex_coord;
	uniform mat4 u_transform;
	uniform vec4 u_tex_rect;
	varying vec2 v_sample_coord;
	void main()
	{
	v_sample_coord = a_tex_coord * u_tex_rect.zw + u_tex_rect.xy;
	gl_Position = u_transform * a_coord;
	}
	)"";

	static const char * s_FS_Texture = R""(
	precision highp float;
	uniform sampler2D u_sampler;
	uniform vec4 u_color;
	varying vec2 v_sample_coord;
	void main()
	{
	gl_FragColor = texture2D(u_sampler, v_sample_coord) * u_color;
	}
	)"";

	static const char * s_FS_Texture_no_sampler = R""(
	precision highp float;
	uniform vec4 u_color;
	void main()
	{
	gl_FragColor = u_color;
	}
	)"";

	static const char * s_FS_Texture_g = R""(
	precision highp float;
	uniform sampler2D u_sampler;
	uniform vec4 u_color;
	varying vec2 v_sample_coord;
	const highp vec3 grey = vec3(0.21, 0.71, 0.08);
	void main()
	{
	vec4 c = texture2D(u_sampler, v_sample_coord);
	float i = dot(c.rgb, grey);
	gl_FragColor = vec4(i, i, i, c.w) * u_color;
	}
	)"";

	static const char * s_FS_Texture_A = R""(
	precision highp float;
	uniform sampler2D u_sampler;
	uniform vec4 u_color;
	varying vec2 v_sample_coord;
	void main()
	{
	float a = texture2D(u_sampler, v_sample_coord).w;
	gl_FragColor = vec4(u_color.rgb, u_color.w * a);
	}
	)"";

	static const char * s_FS_Texture_Ag = R""(
	precision highp float;
	uniform sampler2D u_sampler;
	uniform vec4 u_color;
	varying vec2 v_sample_coord;
	void main()
	{
	float i = texture2D(u_sampler, v_sample_coord).w;
	gl_FragColor = vec4(i, i, i, 1) * u_color;
	}
	)"";

}}
